/*  ___ _  ____  __ _  _    ___       _ _          
 * | _ \ |/ /  \/  | \| |  / _ \ _ _ | (_)_ _  ___ 
 * |  _/ ' <| |\/| | .` | | (_) | ' \| | | ' \/ -_)
 * |_| |_|\_\_|  |_|_|\_|  \___/|_||_|_|_|_||_\___|
 */
#ifndef __PKMNONLINE_ANIMATION_H__
#define __PKMNONLINE_ANIMATION_H__
#include <windows.h>
#include <gl/gl.h> /* OpenGL */
#include "texturemanager.h"

enum {
	LOOP_CONTINUOUS,
	LOOP_ALTERNATE,
};

class CAnimation {
public:
	CAnimation(const char *szFileName, int nAnimations, int nFrames, float flFrameWidth, float flFrameHeight, float flSpeed);

	void	Render(int nX, int nY);
	void	Start() { m_bRunning = true; }

	void	Stop(int nFrame = -1) 
	{
		m_bRunning = false; 
		if (nFrame != -1)
			SetFrame(nFrame);
	}

	int		GetFrame() const { return m_nFrame; }
	int		GetAnimation() const { return m_nAni; }
	float	GetSpeed() const { return m_flSpeed; }
	bool	IsAnimating() const { return m_bRunning; }

	// TODO: Add sanity checks to the functions below.
	void	SetFrame(int nFrame) { m_nFrame = nFrame; }
	void	SetAnimation(int nAni) { m_nAni = nAni; }
	void	SetSpeed(float flSpeed) { m_flSpeed = flSpeed; }
	void	SetMode(int nMode) { m_nAniMode = nMode; }


private:
	CTexture *m_pTexture;
	int		  m_nFrames;
	int		  m_nCount;
	bool      m_bRunning;
	float     m_flLastFrame;
	float	  m_flSpeed;
	float	  m_flFrameWidth;
	float	  m_flFrameHeight;
	float	  m_flFrameTexWidth;
	float	  m_flFrameTexHeight;
	int		  m_nFrame;
	int		  m_nAni;
	int       m_nAniDir;
	int       m_nAniMode;
};

#endif /* __PKMNONLINE_ANIMATION_H__ */
